package TestFinal;

import java.util.Scanner;

public class InventorySystem {
    private final Inventory inventory = new Inventory();
    private final Scanner sc = new Scanner(System.in);

    public void start()
    {
        System.out.println("------------库存初始化完成----------");
        System.out.println("------------欢迎来到库存管理系统----------");
        while(true)
        {
            System.out.println("1.查询所有商品信息，2.商品入库，3.商品出库，4.查看指定商品库存数量，5.退出系统");
            int choice = sc.nextInt();
            switch(choice)
            {
                case 1:
                    choose1();
                    break;
                case 2:
                    choose2();
                    break;
                case 3:
                    choose3();
                    break;
                case 4:
                    choose4();
                    break;
                case 5:
                    choose5();
                    return;
                default:
                    System.out.println("输入的数字有误，请重新输入！");
            }
        }
    }

    public void choose1()
    {
        System.out.println(inventory.showProducts());;
    }

    public void choose2()
    {
        System.out.println("------------请依次输入商品名称,价格,数量（用英文逗号隔开）----------");
        String product = sc.next();
        inventory.addProductQuantity(inventory.returnProduct(product));
    }

    public void choose3()
    {
        System.out.println("------------请依次输入商品名称,价格,数量（用英文逗号隔开）----------");
        String product = sc.next();
        inventory.subtractProductQuantity(inventory.returnProduct(product));
    }

    public void choose4()
    {
        System.out.println("------------请输入商品名称----------");
        String product = sc.next();
        System.out.println(inventory.findProductByName(product));
    }

    public void choose5()
    {
        inventory.saveProduct();
        System.out.println("bye bye~");
    }
}
